﻿using Microsoft.Practices.Unity;
using Microsoft.Practices.Unity.Configuration;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Albatross.WPF.Common {
	public class ioc {
		const string SectionName = "unity";
		const string ContainerName = "albatross";
	  
		IUnityContainer _container;
		
		#region singleton
		private ioc() {
			UnityContainer container = new UnityContainer();
			UnityConfigurationSection section = (UnityConfigurationSection)ConfigurationManager.GetSection(SectionName);
			_container = section.Configure(container, ContainerName);
		}

		public static IUnityContainer Container {
			get { return SingletonInternal.Instance._container; }
		}

		private class SingletonInternal {
			// Explicit static constructor to tell C# compiler
			// not to mark typeName as beforefieldinit
			// this ensures the full laziness of the Singleton object
			static SingletonInternal() { }
			internal static readonly ioc Instance = new ioc();
		}
		#endregion

	}
}
